package com.fang.unit;

import java.io.*;

public class TestDriver {
    public static void main(String[] args) throws IOException {

        test08();
    }
    private static void test08() throws IOException {
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("copy5.jpg"));
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("copy6.jpg"));
        int b;
        while((b = bis.read()) != -1){
            bos.write(b^123);
        }
        bis.close();
        bos.close();
    }
    private static void test07() throws IOException {
        FileOutputStream fos = new FileOutputStream("yyy.txt");
        fos.write("我很菜，别笑话我".getBytes());
        fos.close();
    }
    private static void test06() throws IOException {
        FileInputStream fis = new FileInputStream("xxx.txt");
        byte[] arr = new byte[16];
        int a;
        while((a = fis.read(arr)) != -1){
            System.out.println(new String(arr,0,a));
        }
    }
    private static void test05() throws IOException {
        FileInputStream file1 = new FileInputStream("范文夺 - 我的宝贝.mp3");
        FileOutputStream file2 = new FileOutputStream("copy4.mp3");
        //int a = file1.available();
        //System.out.println(a);
        byte[] arr = new byte[1024 * 1024];
        int a ;
        while((a = file1.read(arr)) != -1){
            file2.write(arr);
        }
        file1.close();
        file2.close();
    }
    private static void test04() throws IOException {
        FileInputStream file1 = new FileInputStream("范文夺 - 我的宝贝.mp3");
        FileOutputStream file2 = new FileOutputStream("copy3.mp3");
        //int a = file1.available();
        //System.out.println(a);
        byte[] arr = new byte[file1.available()];
      int a = file1.read(arr);
        file2.write(arr);
        file1.close();
        file2.close();
    }
    private static void test02() throws IOException {
        FileInputStream file1 = new FileInputStream("范文夺 - 我的宝贝.mp3");
        FileOutputStream file2 = new FileOutputStream("copy2.mp3");
        int b;
        while((b = file1.read()) != -1){
            file2.write(b);
        }
        file1.close();
        file2.close();
    }
    private static void test01() throws IOException {
        FileInputStream file1 = new FileInputStream("zhouxingchi.jpg");
        FileOutputStream file2 = new FileOutputStream("copy.jpg");
        int b;
        while((b = file1.read()) != -1){
            file2.write(b);
        }
        file1.close();
        file2.close();
    }
}
